package com.zzyl.controller;

import com.zzyl.base.PageResponse;
import com.zzyl.base.ResponseResult;
import com.zzyl.service.NursingLevelService;
import com.zzyl.vo.NursingLevelVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Description NursingLevelController
 * @Author xulang
 * @Date 2025-08-30
 */
@RestController
@RequestMapping("/nursingLevel")
public class NursingLevelController {

    @Autowired
    private NursingLevelService nursingLevelService;


    @GetMapping("/listAll")
    public ResponseResult getAllNursingLevel(){
        nursingLevelService.getAllNursingLevel();
        return ResponseResult.success();
    }

    @PostMapping("/insert")
    public ResponseResult addNursingLevel(@RequestBody NursingLevelVo nursingLevelVo){
        nursingLevelService.addNursingLevel(nursingLevelVo);
        return ResponseResult.success();
    }

    @GetMapping("/listByPage")
    public ResponseResult<PageResponse<NursingLevelVo>> getByPageNursingLevel(
            @RequestParam(value = "name",required = false)String name,
            @RequestParam(value = "pageNum",defaultValue = "1")Integer pageNum,
            @RequestParam(value = "pageSize",defaultValue = "10")Integer pageSize,
            @RequestParam(value = "status",required = false)Integer status){
            PageResponse<NursingLevelVo> nursingLevelVoPageInfo = nursingLevelService.getBypageNursingLevel(name,pageNum,pageSize,status);
            return ResponseResult.success(nursingLevelVoPageInfo);
    }

    @GetMapping("/{id}")
    public ResponseResult<NursingLevelVo> getNursingLevelById(@PathVariable("id") Long id){
        NursingLevelVo nursingLevelVo = nursingLevelService.getNursingLevelById(id);
        return ResponseResult.success(nursingLevelVo);
    }

    @PutMapping("/update")
    public ResponseResult updateNursingLevel(@RequestBody NursingLevelVo nursingLevelVo){
        nursingLevelService.updateNursingLevel(nursingLevelVo);
        return ResponseResult.success();
    }

    @DeleteMapping("/delete/{id}")
    public ResponseResult deleteNursingLevel(@PathVariable("id") Long id){
        nursingLevelService.deleteNursingLevel(id);
        return ResponseResult.success();
    }

    @PutMapping("/{id}/status/{status}")
    public ResponseResult enableAndDisableNursingLevel(@PathVariable("id") Long id,@PathVariable("status") Integer status){
        nursingLevelService.enableAndDisableNursingLevel(id,status);
        return ResponseResult.success();
    }
}
